﻿using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;

public enum enumErrorNo
{
    Fail = -1
        , Success = 0, ErrorWrongFormat,
    ErrorWrongArgument
        , ErrorNotFind = 100, ErrorFind, ErrorNotExist, ErrorExist, ErrorNotEmpty,
    ErrorEmpty
        , ErrorOpen = 200, ErrorRead, ErrorWrite, ErrorClose, ErrorDelete
}


namespace FormBase
{
    public class CLastError
    {
        public int miLastError { get; private set; }
        public string msLastError { get; private set; }
        public CLastError()
        {
            ClearLastError();
        }
        public bool IsLastError()
        {
            if (miLastError == (int)enumErrorNo.Success)
                return false;
            else
                return true;
        }

        public void ClearLastError()
        {
            SetLastError(enumErrorNo.Success, string.Empty);
        }
        public void SetLastError(string sError)
        {
            SetLastError(enumErrorNo.Fail, string.Empty);
        }

        public void SetLastError(int iError, string sError)
        {
            miLastError = iError;
            msLastError = sError;
        }
        public void SetLastError(enumErrorNo pError, string sError)
        {
            SetLastError((int)pError, sError);
        }
        public override string ToString()
        {
            return string.Format("{0},{1}", miLastError, msLastError);
        }
    }
}
